<?php

namespace IDock\Insurance\HBIC\Response;

use IDock\Http\Response;

class HBICTokenResponse extends AllHBICResponse
{
    protected $code = '';

    protected $message = '';

    protected $respTime = '';

    protected $data = '';

    public function resolve(): Response
    {
        $body = $this->getBody();
        $data = json_decode($body,true);
        $status = $data['status'] ?? '';
        if($status == '500'){
            throw new \Exception("获取恒邦Token失败：".$data['detail'] ?? '');
        }
        $this->setBody($data);
        return $this;
    }

    /**
     * @return string
     */
    public function getLogicCode(): string
    {
        $this->code = $this->get('code','');
        return $this->code;
    }

    /**
     * @return string
     */
    public function getMessage(): string
    {
        $this->message = $this->get('message','');
        return $this->message;
    }

    /**
     * @return string
     */
    public function getRespTime(): string
    {
        $this->respTime = $this->get('respTime','');
        return $this->respTime;
    }

    /**
     * @return array
     */
    public function getData()
    {
        $this->data = $this->get('BODY','');
        return $this->data;
    }


}